/** 
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package com.tompai.datagather.tencent;

import java.time.Clock;
import java.time.LocalDate;

import org.apache.log4j.Logger;

import com.tompai.datagather.model.CrawlDatum;

/**
 * @desc: datagather-tools
 * @name: TencrawlerTask.java
 * @author: tompai
 * @createTime: 2018年5月2日 上午12:13:46
 * @history:
 * @version: v1.0
 */

public class TenNewsTask implements Runnable {

	private static final Logger logger = Logger.getLogger(TenNewsTask.class);
	
	@Override
	public void run() {
		// TODO Auto-generated method stub

		try {

			Clock clock = Clock.systemDefaultZone();// 获取系统默认时区 (当前瞬时时间 )
			long currentTime = clock.millis();
			// long begainPoint=1525191474487L;
			LocalDate date = LocalDate.now();

			//logger.info("current date:"+date);
			TenNewsCrawler crawler = new TenNewsCrawler("./temp/json_crawler", true);
			String url = "http://roll.news.qq.com/interface/cpcroll.php?callback=rollback&site=news&mode=1&cata=&date="
					+ date + "&page=1&_=" + currentTime;
			logger.info("current URL:"+url);
			crawler.addSeed(new CrawlDatum(url)
					.meta("method", "GET")
					.meta("outputData", "id=a")
					.meta("url", url)
					.type("rollnews")
					.meta("depth", 1));
			
			crawler.start(1);
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
